package servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * 06-重定向
 * 需求：重定向到Demo10Servlet
 */
@WebServlet("/demo09")
public class Demo09Servlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("Demo09Servlet");
        //①操作响应状态码
        //resp.setStatus(302);
        //②操作响应头location
        //resp.setHeader("location","demo10");

        resp.sendRedirect("demo10");

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
